package com.xxx.springcloud.service.impl;

import com.xxx.springcloud.service.MessageService;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.support.MessageBuilder;

import javax.annotation.Resource;

@EnableBinding(Source.class)
public class MessageServiceImpl implements MessageService {

    @Resource
    private MessageChannel output;

    @Override
    public boolean send(String msg) {
        System.out.println(msg);
        return this.output.send(MessageBuilder.withPayload(msg).build());
    }

}
